//
//  YHYMineActivityViewController.m
//  Home
//
//  Created by 杨泓晔 on 16/6/22.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYMineActivityViewController.h"
#import "YHYDesignerPTableViewCell.h"
#import "YHYActivityMessageViewController.h"//基本信息
#import "YHYCompanyViewController.h"//公司图片
#import "YHYActivityIntroductionViewController.h"//活动介绍
#import "WSCustomPickerView.h"
#import "YHYAcitvityButtonTableViewCell.h"
@interface YHYMineActivityViewController ()<UITableViewDataSource,UITableViewDelegate,WSCustomPickerViewDelegate>
@property (nonatomic,strong)  UITableView *myTableView;
@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) UIImage *headImage;
//@property (nonatomic, strong) WSHeaderActView *headerAV;
//@property (nonatomic, strong) WSCustomPickerView *customPicker;
@property (nonatomic, strong) NSMutableArray *contentAry;
@property (nonatomic,strong)  UITextField *nameTextField;
//选择器
@property (nonatomic, strong) WSCustomPickerView *customPicker;

@property (nonatomic, strong) NSString *addressStr;


@end

@implementation YHYMineActivityViewController


-(void) viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=NO;
    self.tabBarController.tabBar.hidden=YES;
    
}

-(void) viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=NO;
    self.tabBarController.tabBar.hidden=NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatView];
    self.title = @"发布活动";
}

- (void)creatView{
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(Back:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    
    self.view.backgroundColor = LV;
    self.array = [NSArray arrayWithObjects:@"基本信息", @"公司图片", @"发布范围", @"活动介绍", @"可见人群设定", nil];
    
    self.myTableView = [UITableView new];
    
    [self.view addSubview:self.myTableView];
    self.myTableView.rowHeight = ROWHEIGHT;
     self.myTableView.sectionFooterHeight = 10;
    [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(self.view);
        make.height.mas_equalTo(self.view);
        make.width.mas_equalTo(self.view);
        
    }];
    
    
    _myTableView.scrollEnabled = NO;
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.backgroundColor = LV;
    //[self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.myTableView registerClass:[YHYDesignerPTableViewCell class] forCellReuseIdentifier:@"YHYDesignerPTableViewCell"];
    [self.myTableView registerClass:[YHYAcitvityButtonTableViewCell class] forCellReuseIdentifier:@"cell"];
    [[UITableViewHeaderFooterView appearance] setTintColor:LV];
    _myTableView.separatorStyle = NO;

    UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 180)];
    _myTableView.tableFooterView = footView;
    footView.backgroundColor = [UIColor redColor];
        [_myTableView reloadData];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return _array.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 4) {
        return 2;
    }

    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellstr = @"YHYDesignerPTableViewCell";
    YHYDesignerPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellstr];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.xmLabel.text = [_array objectAtIndex:indexPath.section];
    
    if (indexPath.section == 1) {
        cell.myimageView.image = [UIImage imageNamed:@"bibi"];
    }
    
    if (indexPath.section == 2) {
        if (_addressStr != 0) {
            cell.WXlabel.text = _addressStr;
        }
    }
    
    
//    if (indexPath.section == 4) {
//        if (indexPath.row == 1) {
//            YHYAcitvityButtonTableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:@"cell"];
//            cell1.backgroundColor = [UIColor redColor];
//             cell1.selectionStyle = UITableViewCellSelectionStyleNone;
//            return cell1;
//        }
//    }
    return cell;
    
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0;
    }
    
    else{
    return 10 * AUTO_HEIGHT;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        YHYActivityMessageViewController *message = [YHYActivityMessageViewController new];
        [self.navigationController pushViewController:message animated:YES];
    }
    if (indexPath.section == 1) {
        YHYCompanyViewController *company = [YHYCompanyViewController new];
        [self.navigationController pushViewController:company animated:YES];
    }
    if (indexPath.section == 2) {
        self.customPicker = nil;
        self.customPicker = [[WSCustomPickerView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.customPicker.delegate = self;
                [self.view addSubview:_customPicker];
        [self.customPicker showPicker];
    }
    if (indexPath.section == 3) {//活动介绍
        YHYActivityIntroductionViewController *activy = [YHYActivityIntroductionViewController new];
        [self.navigationController pushViewController:activy animated:YES];
    }
}

- (void)sendAddressInfo:(NSString *)address{
    _addressStr = address;
    [_myTableView reloadData];
}

//返回按钮
-(void) Back:(UIButton *) btn
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
